﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DCMS_Framework;

namespace BusinessObjects {

  /// <summary>
  /// Object representing a city's zipcode; inherits from Country
  /// </summary>
  public class CityZipcode : Country {

    int zipcodeId;
    string zipcode, city;

    #region - Properties -

    /// <summary>
    /// Gets a value indicating whether this <see cref="CityZipcode"/> is isnew.
    /// </summary>
    /// <value>
    ///   <c>true</c> if isnew; otherwise, <c>false</c>.
    /// </value>
    public bool Isnew {
      get {
        if ( this.ZipcodeId == 0 ) {
          return true;
        } else {
          return false;
        }
      }
    }

    /// <summary>
    /// Gets or sets the zipcode id.
    /// </summary>
    /// <value>
    /// The zipcode id.
    /// </value>
    public int ZipcodeId {
      get { return zipcodeId; }
      set {
        SetField( ref zipcodeId, value, "ZipcodeId" );
      }
    }

    /// <summary>
    /// Gets or sets the city name.
    /// </summary>
    /// <value>
    /// The city name.
    /// </value>
    public string City {
      get { return city; }
      set {
        SetField( ref city, value, "City" );
      }
    }

    /// <summary>
    /// Gets or sets the zipcode.
    /// </summary>
    /// <value>
    /// The zipcode.
    /// </value>
    public string Zipcode {
      get { return zipcode; }
      set {
        SetField( ref zipcode, value, "Zipcode" );
      }
    }

    #endregion

    #region - Constructors -

    /// <summary>
    /// Initializes a new instance of the <see cref="CityZipcode"/> class.
    /// </summary>
    public CityZipcode( ) {
      this.MarkClean( );
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="CityZipcode"/> class.
    /// </summary>
    /// <param name="zipcode">The zipcode.</param>
    /// <param name="city">The city.</param>
    /// <param name="countryId">The country id.</param>
    public CityZipcode( string zipcode, string city, int countryId )
      : this( ) {
      this.Zipcode = zipcode;
      this.City = city;
      this.CountryId = countryId;
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="CityZipcode"/> class.
    /// </summary>
    /// <param name="country">The country.</param>
    public CityZipcode( Country country )
      : this( ) {
      this.CountryName = country.CountryName;
      this.CountryId = country.CountryId;
      this.CountryCode = country.CountryCode;
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="CityZipcode"/> class.
    /// </summary>
    /// <param name="id">The id.</param>
    /// <param name="zipcode">The zipcode.</param>
    /// <param name="city">The city.</param>
    /// <param name="country">The country.</param>
    public CityZipcode( int id, string zipcode, string city, Country country )
      : this( country ) {
      this.ZipcodeId = id;
      this.Zipcode = zipcode;
      this.City = city;
      //this.CountryName = country.CountryName;
      //this.CountryId = country.CountryId;
      //this.CountryCode = country.CountryCode;
    }

    #endregion

    /// <summary>
    /// Copies this instance.
    /// </summary>
    /// <returns></returns>
    public CityZipcode Copy( ) {
      CityZipcode copy = new CityZipcode( );
      copy.ZipcodeId = this.ZipcodeId;
      copy.Zipcode = this.Zipcode;
      copy.City = this.City;
      copy.CountryCode = this.CountryCode;
      copy.CountryId = this.CountryId;
      copy.CountryName = this.CountryName;

      return copy;
    }


  }
}
